package com.tourscool.springboot.starter.inquiry.controller;

import com.tourscool.springboot.starter.inquiry.core.RequestMethodItem;
import com.tourscool.springboot.starter.inquiry.service.CollectService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;
import java.util.Map;

/**
 * @author Cedric
 * @date 2020/10/23 20:21
 * @description 服务查询控制器
 */
@Slf4j
@Controller
public class InquiryController {

    @Autowired
    private CollectService collectService;

    @GetMapping("/inquiry")
    public ModelAndView inquiry(@RequestParam(defaultValue = "service-inquiry") String key) {
        ModelAndView view = new ModelAndView("inquiry");
        Map<String, List<RequestMethodItem>> serviceInterfaceMap = collectService.getServiceInterfaceMap();
        view.addObject("serviceInterfaceMap", serviceInterfaceMap);
        view.addObject("requestMethodItemList", serviceInterfaceMap.get(key));
        return view;
    }

}
